#pragma once

#include <memory>
#include <vector>
#include "BattleShip.h"
#include "Algorithm.h"
//#include "PartOfBattle.h"

#define MAX_PART 4
#define MOD_3_AL 0
#define MOD_5_AL 1

class Utils;
#if (_MSC_VER == 1700)  
typedef std::shared_ptr<Utils> UtilsPtr;
#else
typedef boost::shared_ptr<Utils> UtilsPtr;
#endif

#if (_MSC_VER == 1700)  
#include <thread>
typedef std::thread ThreadType;
#else
#include <boost/thread.hpp>
typedef boost::thread ThreadType;
#endif

typedef std::vector<Point> PointArray;

typedef int BoardType [5][4];

class Utils
{
public:
	enum AI_State {BEGIN,FINDING,FOUND_ONE,FOUND_TWO};
private:
	static UtilsPtr m_Instance;
	Utils();
	float m_add[MAX_H][MAX_V];
	BattleShipPtr m_battle;
	int m_state;
	Ship::Rotation m_direction;
	Point m_lastPoint;
	AlgorithmPtr m_algorithm;
	bool m_swap;
	void SetAirCraft(BattleShipPtr battle, int ship [4]);

public:
	~Utils();
	static UtilsPtr GetInstance();
	void Initialize(int al);
	Point GuessPos();
	void FoundShip(Point p, Ship::TypeOfShip _type);
	void ProcessPos(Point p, bool value);
	void EndSet();
	void Swap(int &x, int &j);
public:
	void SetBoard(BoardType &result);
};

